#include<bitset>
#include<cmath>
using std::bitset,std::min;
class SmallestInfiniteSet {
public:
    bitset<1002> _set;
    int smallest=1;
    SmallestInfiniteSet() {
        _set.set();
    }
    int popSmallest() {
        size_t ret=smallest;
        _set.set(smallest,false);
        while(!_set.test(++smallest));
        return ret;
    }
    
    void addBack(int num) {
        smallest=min(num,smallest);
        _set.set(num);
    }
};
